﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OutlineDemo : MonoBehaviour
{
    public OutlineSystem outlineSystem;
    // Start is called before the first frame update
    void Start()
    {

    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {  //当敲下左键时
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);    //发出一条射线
            RaycastHit hit; //射线命中的对象
            if (Physics.Raycast(ray, out hit, 100f))        //最大长度设置为100f
            {
                if (outlineSystem.IsOutline(hit.transform.gameObject))
                    outlineSystem.CancelOutline(hit.transform.gameObject);
                else
                    outlineSystem.AddOutline(hit.transform.gameObject);
            }
        }
    }
}
